package com.blacktech.dbu.meta.entity;

import com.blacktech.dbu.core.annotation.Searchable;
import com.blacktech.dbu.core.common.BaseEntity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;

/**
 * 产品信息
 * <p>
 * 一个产品下面有多张表,比如RMS是产品名称，其下有多张表，比如RMS_RULE、RMS_FACTOR表等等
 *
 * @author yanyunsong
 */
@EqualsAndHashCode(callSuper = true)
@Data
@Entity
@Table(name = "dbu_product")
public class DbuProduct extends BaseEntity {
    /**
     * 产品代号
     */
    @Searchable(value = "产品代号", priority = 1)
    @Column(name = "product_code", unique = true)
    private String productCode;

    /**
     * 产品名称
     */
    @Searchable(value = "产品名称", priority = 2)
    @Column(name = "product_name")
    private String productName;

    /**
     * 产品描述
     */
    @Searchable(value = "产品描述", priority = 3)
    @Column(name = "product_desc")
    private String productDesc;

    /**
     * 产品的数据库模式列表
     */
    @OneToMany(mappedBy = "product", cascade = CascadeType.ALL, fetch = FetchType.LAZY, orphanRemoval = true)
    @JsonIgnore
    private List<DbuSchema> schemas;
}